package com.tencent.iov.cowin.befsale.clue.repository.clue.impl;

import com.github.pagehelper.Page;
import com.tencent.iov.cowin.befsale.clue.controller.clue.vo.request.QueryClueRequest;
import com.tencent.iov.cowin.befsale.clue.controller.clue.vo.response.ClueIntentionGrade;
import com.tencent.iov.cowin.befsale.clue.controller.clue.vo.response.ClueToMqResponse;
import com.tencent.iov.cowin.befsale.clue.controller.clue.vo.response.clueIssueConfigResponse;
import com.tencent.iov.cowin.befsale.clue.controller.cus.vo.request.ClueIntentionGradeDataRequest;
import com.tencent.iov.cowin.befsale.clue.dao.clue.ClueDao;
import com.tencent.iov.cowin.befsale.clue.domain.clue.po.Clue;
import com.tencent.iov.cowin.befsale.clue.repository.clue.ClueManager;
import com.tencent.iov.cowin.befsale.clue.value.contants.ServiceConstant;
import com.software.boot.dao.annotation.TargetDataSource;
import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * @Describe: 线索信息表_Manager实现层
 * @author: whp
 * @created: 2021-12-21 16:16:04
 * @version: 1.0
 */
@Service
public class ClueManagerImpl implements ClueManager {

    @Autowired
    private ClueDao clueDao;

    /**
     * 通过ID获取详细信息
     *
     * @param: id
     * @return: Clue对象
     */
    @Override
    @TargetDataSource(ServiceConstant.QW_SALE_READ)
    public Clue getDetailById(Long id) {
        return clueDao.getDetailById(id);
    }

    /**
     * 单条数据插入Clue
     *
     * @param request
     * @return 插入的条数
     */
    @Override
    @TargetDataSource(ServiceConstant.QW_SALE_WRITE)
    public int insert(Clue request) {
        return clueDao.insert(request);
    }

    /**
     * 批量插入Clue
     *
     * @param requests
     * @return 批量插入的条数
     */
    @Override
    @TargetDataSource(ServiceConstant.QW_SALE_WRITE)
    public int insertBatch(List<Clue> requests) {
        return clueDao.insertBatch(requests);
    }

    /**
     * 单条Clue更新
     *
     * @param request
     * @return 更新的条数
     */
    @Override
    @TargetDataSource(ServiceConstant.QW_SALE_WRITE)
    public int update(Clue request) {
        return clueDao.update(request);
    }

    @Override
    @TargetDataSource(ServiceConstant.QW_SALE_WRITE)
    public int updateByIds(Clue request) {
        return clueDao.updateByIds(request);
    }


    /**
     * 单条Clue删除
     *
     * @param id
     * @return 删除的条数
     */
    @Override
    public int delete(Integer id) {
        return clueDao.delete(id);
    }

    /**
     * 根据条件查询对象list列表
     *
     * @param request
     * @return 查询结果
     */
    @Override
    @TargetDataSource(ServiceConstant.QW_SALE_READ)
    public List<Clue> getListByParam(Clue request) {
        return clueDao.getListByParam(request);
    }

    /**
     * 根据条件查询对象page记录
     *
     * @param request
     * @param rowBounds
     * @return 分页对象
     */
    @Override
    @TargetDataSource(ServiceConstant.QW_SALE_READ)
    public Page<Clue> getPageByParam(Clue request, RowBounds rowBounds) {
        return clueDao.getPageByParam(request, rowBounds);
    }

    @Override
    @TargetDataSource(ServiceConstant.QW_SALE_READ)
    public Clue getOneByParam(Clue request) {
        return clueDao.getOneByParam(request);
    }

    @Override
    public List<ClueIntentionGrade> getClueIntentionGradeData(ClueIntentionGradeDataRequest clueIntentionGradeDataRequest) {
        return clueDao.getClueIntentionGradeData(clueIntentionGradeDataRequest);
    }

    /**
     * 根据条件获取顾问新增线索数量
     * add by zly
     * 2022-01-15
     * @param clueDataRequest
     * @return
     */
    @Override
    public Long getEmpClueNumByTime(ClueIntentionGradeDataRequest clueDataRequest) {
        return clueDao.getEmpClueNumByTime(clueDataRequest);
    }

    /**
     * 根据条件获取顾问跟进下单线索
     * add by zly
     * 2022-01-16
     * @param clueDataRequest
     * @return
     */
    @Override
    public Long getEmpFollowOrderNum(ClueIntentionGradeDataRequest clueDataRequest) {
        return clueDao.getEmpFollowOrderNum(clueDataRequest);
    }

    /**
     * 根据条件查询顾问对应线索数量
     * add by zly
     * 2022-01-16
     * @param clueDataRequest
     * @return
     */
    @Override
    public Long getEmpNumByClueStatus(ClueIntentionGradeDataRequest clueDataRequest) {
        return clueDao.getEmpNumByClueStatus(clueDataRequest);
    }

    /**
     * 根据 线索分配规则查询线索数量
     * add by zly
     * @param queryClueRequest
     * @return
     */
    @Override
    public Integer getclueCountByParam(QueryClueRequest queryClueRequest) {
        return clueDao.getclueCountByParam(queryClueRequest);
    }

    /**
     * 根据 线索分配规则分页查询线索信息
     *  add by zly
     *  2022-01-22
     * @param queryClueRequest
     * @return
     */
    @Override
    public List<ClueToMqResponse> queryCluePageRequest(QueryClueRequest queryClueRequest) {
        return clueDao.queryCluePageRequest(queryClueRequest);
    }

    @Override
    public List<clueIssueConfigResponse> getConfigList() {
        return clueDao.getConfigList();
    }

    @Override
    public int updateClueStatus(Clue clue) {
        return clueDao.updateClueStatus(clue);
    }
}
